/**
 *
 */
package com.wedroid.api.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.demo2do.core.utils.JsonUtils;
import com.wedroid.api.service.AdminService;

/**
 * @author lute
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    /**
     * Return the basic administrative statistics
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/basic")
    public String getBasicStats() {
        Map<String, Integer> basicStats = new HashMap<>();
        basicStats.put("groups", adminService.countGroups());
        basicStats.put("groupMembers", adminService.countGroupMembers());
        basicStats.put("messages", adminService.countMessages());
        basicStats.put("commands", adminService.countCommands());
        return JsonUtils.toJsonString(basicStats);
    }

}
